Type.registerNamespace("Telerik.Web.UI.Scheduler.Views.Timeline");
(function(e,d,a,c){var b=60000;
var f=b*60;
var g=f*24;
c.ModelBase=function(h){this._owner=h;
this._settings=this._owner.get_timelineViewSettings()||{};
this._defaultHeaderDateFormat="d";
};
c.ModelBase.prototype={get_visibleRangeStart:function(){return d.add(this._owner.get_selectedDate(),this._getStartTime());
},get_visibleRangeEnd:function(){var h=new d(this.get_visibleRangeStart());
return h.add(this._getTimeViewDuration()).toDate();
},get_headerDateFormat:function(){if(!this._settings){return this._defaultHeaderDateFormat;
}return this._settings.headerDateFormat||this._defaultHeaderDateFormat;
},get_columnHeaderDateFormat:function(){return this._settings.columnHeaderDateFormat||"d";
},get_nextPeriodDate:function(){return new Date(this.get_visibleRangeEnd().getTime());
},get_previousPeriodDate:function(){var h=new d(this.get_visibleRangeStart());
return h.add(-this._getTimeViewDuration().get_ticks()).toDate();
},updateDraggingAppointmentSize:function(h,n,j){var o=n.parentNode;
var i=o.cells[o.cells.length-1];
var k=h.offsetLeft;
var l=i.offsetLeft+i.offsetWidth;
var m=l-n.offsetLeft-k;
h.style.width=Math.min(m,j)+"px";
},updateResizingAppointmentSize:function(i,l){var j=i.parentNode.parentNode;
var m=l.offsetLeft+l.offsetWidth;
var k=i.offsetLeft;
var h=m-j.offsetLeft-k;
i.style.width=h+"px";
},_getMaxAppointmentGrowth:function(){return this._getNumberOfSlots();
},_getNumberOfSlots:function(){return this._settings.numberOfSlots||3;
},_getTimeLabelSpan:function(){return this._settings.timeLabelSpan||1;
},_getSlotDuration:function(){return this._settings.slotDuration||g;
},_getStartTime:function(){return this._settings.startTime||0;
},isVisible:function(h){return h._isInRange(this.get_visibleRangeStart(),this.get_visibleRangeEnd());
},_getTimeViewDuration:function(){return new a(this._getNumberOfSlots()*this._getSlotDuration());
}};
c.ModelBase.registerClass("Telerik.Web.UI.Scheduler.Views.Timeline.ModelBase",null,Telerik.Web.UI.ISchedulerModel);
c.Model=function(h){c.Model.initializeBase(this,[h]);
this._slotDurationInMinutes=this._getSlotDuration()/b;
if(Telerik.Web.UI.Scheduler.Rendering.HorizontalBlockCollection){this._allDayBlocks=new Telerik.Web.UI.Scheduler.Rendering.HorizontalBlockCollection();
}};
c.Model.prototype={initialize:function(){},addToBlocks:function(h){this._allDayBlocks.add(h);
},removeFromBlock:function(h){this._allDayBlocks.remove(h);
},getTimeSlotFromDomElement:function(j){var i=this._getRawIndexFromDomElement(j);
var h=this._getTimeFromDomElement(j);
return new c.TimeSlot(i,h,this._slotDurationInMinutes,j);
},getDurationOfMovedAppointment:function(h){return h.get_duration();
},_getTimeFromDomElement:function(h){var i=this._getRawIndexFromDomElement(h);
return this._getTimeFromIndex(i);
},_getTimeFromIndex:function(i){var h=this.get_visibleRangeStart();
Telerik.Web.UI.RadScheduler._incrementTime(h,0,this._slotDurationInMinutes*i.intervalIndex);
return h;
},_getRawIndexFromDomElement:function(h){while(h&&(h.tagName.toUpperCase()!="TD")){h=h.parentNode;
}if(h){return{intervalIndex:h.cellIndex};
}return null;
},_getRawIndexFromStartTime:function(h){var i=d.subtract(new Date(h),this.get_visibleRangeStart());
return{intervalIndex:Math.max(0,Math.floor(i/this._getSlotDuration()))};
},_getAllDayTimeSlotForAppointmentPart:function(h){return this._getAllDayTimeSlotFromStartTime(h.start);
},_getAllDayTimeSlotFromStartTime:function(h){var i=this._getRawIndexFromStartTime(h);
var j=this._getDomElementFromRawIndex(i.intervalIndex);
return new c.TimeSlot({intervalIndex:i.intervalIndex},0,0,j);
},getTimeSlotForAppointment:function(h){return this._getAllDayTimeSlotFromStartTime(h.get_start());
},_getDomElementFromRawIndex:function(h){return e(".rsTimelineView .rsAllDayRow",this._owner.get_element()).children()[h];
},_getRenderer:function(){if(!this._renderer){this._renderer=new Telerik.Web.UI.Scheduler.Rendering.TimelineViewRenderer(this);
}return this._renderer;
}};
c.Model.registerClass("Telerik.Web.UI.Scheduler.Views.Timeline.Model",c.ModelBase);
c.TimeSlot=function(i,h,k,j){this._rawIndex=i;
this._startTime=h;
this._durationInMinutes=k;
this._domElement=j;
};
c.TimeSlot.prototype={get_index:function(){var h=this.get_rawIndex();
return String.format("{0}",h.intervalIndex);
},get_rawIndex:function(){return this._rawIndex;
},get_startTime:function(){return this._startTime;
},get_endTime:function(){return d.add(this.get_startTime(),this.get_duration());
},get_duration:function(){return this.get_durationInMinutes()*b;
},get_durationInMinutes:function(){return this._durationInMinutes;
},get_isAllDay:function(){return true;
},get_domElement:function(){return this._domElement;
}};
c.TimeSlot.registerClass("Telerik.Web.UI.Scheduler.Views.Timeline.TimeSlot",null,Telerik.Web.UI.ISchedulerTimeSlot);
})($telerik.$,Telerik.Web.UI.Scheduler.DateTime,Telerik.Web.UI.Scheduler.TimeSpan,Telerik.Web.UI.Scheduler.Views.Timeline);
